package com.atguigu.classes.preconditions;

import java.util.Random;
import java.util.Scanner;

/**
 * @program: myIDEA
 * @description: 猜随机数
 * @author: Mr.zjx
 * create: 2021-07-06-11-28
 **/
public class Test12 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Random random = new Random();
        //产生1-100之间的随机数
        int i = random.nextInt(100) + 1;
        while (true){
            int number = scanner.nextInt();
            if(number > i){
                System.out.println("猜大了，请重新输入：");
            }else if (number <i ){
                System.out.println("猜小了，请重新输入：");
            }else {
                System.out.println("猜对了");
                break;
            }
        }
    }
}
